package com.byd.sealmanage.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * http异常状态跳转页面配置
 * @author fm
 * @date 2021/08/26
 */
@Configuration
public class ErrorConfig implements ErrorPageRegistrar {

    /**
     * 404（页面找不到时）：跳转至page/404.html页面
     * @param registry
     */
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage[] errorPAges = new ErrorPage[2];
        errorPAges[0] = new ErrorPage(HttpStatus.NOT_FOUND,"/login/notFound");
        errorPAges[1] = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/login/serverError");
        registry.addErrorPages(errorPAges);
    }
}
